package keeto.com.vn.bms.network.task;

import java.io.IOException;
import java.util.ArrayList;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.model.InputDataModel;
import keeto.com.vn.bms.network.IBMSProtocol;
import keeto.com.vn.bms.network.request.SendUpdateComDoctorRequest;
import keeto.com.vn.bms.network.response.SendUpdateComDoctorResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskSendUpdateComDoctor extends AbstractTask {
	private String authenKey;
	private ArrayList<InputDataModel> data;
	private String date;
	public TaskSendUpdateComDoctor(BMSListener listener, IBMSCore core,ArrayList<InputDataModel> data, String date, String authKey) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.authenKey=authKey;
		this.data=data;
		this.date= date;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		SendUpdateComDoctorRequest request= new SendUpdateComDoctorRequest();
		request.setAuthKey(authenKey);
		request.setData(data);
		request.setDate(date);
		SendUpdateComDoctorResponse response= protocol.sendUpdateComDoctor(request);
		for(BMSListener mListener:listener){
			mListener.finishSendUpdateComDoctor(response.getReturnCode(),response.getResultMsg());
		}
		
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for(BMSListener mListener:listener){
			mListener.finishSendUpdateComDoctor(IBMSProtocol.STATUS_CODE_GENERIC_FAIL_CONECTTION,"Failed");
		}
	}

}
